package com.sparsearr.datastructures.itheima.twodimension;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

/**
 * @Author: ZhaoTR
 * @Date: Created in 2025/4/19 18:22
 * @Description: 二维数组
 * @Version: 1.0
 */

public class TwoDimenSionMoney {
    private static final Logger logger = LogManager.getLogger(TwoDimenSionMoney.class);

    public static void main(String[] args) {
        int[][] yearArr = {
                {22, 66, 44},
                {77, 33, 88},
                {25, 45, 65},
                {11, 66, 99}
        };

        int yearSum = 0;
        for (int i = 0; i < yearArr.length; i++) {
            int[] quarterArr = yearArr[i];
            int sum = getSum(quarterArr);
            logger.info("第{}季度的工资为：{}", i + 1, sum);
            yearSum += sum;
        }

        logger.info("全年工资为：{}", yearSum);
    }

    private static int getSum(int[] arr) {
        int sum = 0;
        for (int i = 0; i < arr.length; i++) {
            sum += arr[i];
        }
        return sum;
    }
}
